# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=lua-cliargs
_rockname=lua_cliargs
pkgver=3.0.2
pkgrel=0
pkgdesc="A command-line argument parsing module for Lua"
url="https://github.com/amireh/lua_cliargs"
arch="noarch"
license="MIT"
checkdepends="
	lua-busted
	lua-cjson
	lua-yaml
	"
source="https://github.com/amireh/lua_cliargs/archive/v$pkgver/$_rockname-$pkgver.tar.gz
	support-cjson.patch
	"
builddir="$srcdir/$_rockname-$pkgver"
options="!check"  # avoid circular dependency with lua-busted

_luaversions="5.1 5.2 5.3 5.4"
for _v in $_luaversions; do
	checkdepends="$checkdepends lua$_v"
	# for backward compatibility (Alpine <3.18)
	provides="$provides lua$_v-cliargs=$pkgver-r$pkgrel"
done

check() {
	local lver; for lver in $_luaversions jit; do
		msg "Testing on lua$lver"
		# from_ini - missing aport lua-inifile
		lua$lver /usr/bin/busted --no-coverage --exclude-tags="from_ini"
	done
}

package() {
	local rockdir="$pkgdir/usr/lib/luarocks/rocks-common/$_rockname/$pkgver-1"
	local luadir="$pkgdir/usr/share/lua/common"

	mkdir -p "$luadir"
	cp -r src/* "$luadir"/

	mkdir -p "$rockdir"
	echo 'rock_manifest = {}' > "$rockdir"/rock_manifest
}

sha512sums="
3d9dac4723e8a41284eb28a7d1b5c400add91de055eb59645406929f5091c52bd71640b5f4914597b222b5ce7b43bbc918e4a34a69ce7bae726638bd2447abf8  lua_cliargs-3.0.2.tar.gz
69c1d1118a9a4f270eb458c91c4cb73621e25d9ddede8b9a2892cf551b756abb328f705e69ff1e76b3e59af26dbe2852267e0c765db7d8e8e38f014797edc347  support-cjson.patch
"
